$(".logout").click(function(e) {
	bootbox.confirm("Wollen Sie sich wirklich abmelden?", "Nein", "Ja", function() {
		console.log("User logged out");
	});
});

$(".deleteEntry").click(function(e) {
	bootbox.confirm("Wollen Sie den Eintrag wirklich l&ouml;schen?", "Nein", "Ja", function() {
		console.log("Entry deleted");
	});
});

$(".deleteModel").click(function(e){
	bootbox.confirm("Wollen Sie die Vorlage wirklich l&ouml;schen?", "Nein", "Ja",function(){
		console.log("Model delted");
	})
});

$("#dp").datepicker().on('show', function(ev) {
	var today = new Date();
	var t = today.getDate() + "-" + (today.getMonth() + 1) + "-" + today.getFullYear();
	$('#dp').data({
		date : t
	}).datepicker('update');
});

$("#dp1").datepicker().on('show', function(ev) {
	var today = new Date();
	var t = today.getDate() + "-" + (today.getMonth() + 1) + "-" + today.getFullYear();
	$('#dp1').data({
		date : t
	}).datepicker('update');
});

$("#dp2").datepicker().on('show', function(ev) {
	var today = new Date();
	var t = today.getDate() + "-" + (today.getMonth() + 1) + "-" + today.getFullYear();
	$('#dp2').data({
		date : t
	}).datepicker('update');
});
$("#dp3").datepicker().on('show', function(ev) {
	var today = new Date();
	var t = today.getDate() + "-" + (today.getMonth() + 1) + "-" + today.getFullYear();
	$('#dp3').data({
		date : t
	}).datepicker('update');
});

$("#dp4").datepicker().on('show', function(ev) {
	var today = new Date();
	var t = today.getDate() + "-" + (today.getMonth() + 1) + "-" + today.getFullYear();
	$('#dp4').data({
		date : t
	}).datepicker('update');
});

$("#dp5").datepicker().on('show', function(ev) {
	var t = $("#dp5").value();
	$('#dp5').data({
		date : t
	}).datepicker('update');
});

$("#dpMonths").datepicker().on('show', function(ev) {
	var today = new Date();
	var t = (today.getMonth() + 1) + "-" + today.getFullYear();
	$('#dpMonths').data({
		date : t
	}).datepicker('update');
});

$(document).ready(function() {
	$('.select2').select2();
});

$("#activatePeriod").click(function() {
	var periodActive = document.getElementById('activatePeriod');
	if (periodActive.checked) {
		$("#period").select2("enable");
	} else {
		$("#period").select2("disable");
	}
});

$("#activatePeriod1").click(function() {
	var periodActive = document.getElementById('activatePeriod1');
	if (periodActive.checked) {
		$("#period1").select2("enable");
	} else {
		$("#period1").select2("disable");
	}
});

$("#activatePeriod2").click(function() {
	var periodActive = document.getElementById('activatePeriod2');
	if (periodActive.checked) {
		$("#period2").select2("enable");
	} else {
		$("#period2").select2("disable");
	}
});

$("#activatePeriod3").click(function() {
	var periodActive = document.getElementById('activatePeriod3');
	if (periodActive.checked) {
		$("#period3").select2("enable");
	} else {
		$("#period3").select2("disable");
	}
})






function showModelDialog(e){

	
	
		if(e.options[e.selectedIndex].value=='mod'){
			$('#newModelModal').modal('show');	
		}
	
}

function showCategoryDialog(e){

	
		if(e.options[e.selectedIndex].value=='cat'){
			$('#newCategoryModal').modal('show');	
		}
	
}

function changeInfos(e){

	x=e.options[e.selectedIndex].value;
	l= document.getElementById('cLabel');
	c=document.getElementById('cCat');
	i=document.getElementById('cInput');
	if (x=='1'){
	
		l.placeholder="Kleines Mensamenü";
		i.placeholder="3.40";
		c.selectedIndex='1';

	}else if (x=='2'){
		l.placeholder="Großes Mensamenü";
			c.selectedIndex='1';
				i.placeholder="3.90";

	}else if (x=='3'){
		l.placeholder="Zugfahrt nach Hause";
			c.selectedIndex='3';
				i.placeholder="20.40";
	}

}

function changePeriod(e){
	p=document.getElementById('period4');
 if (e.checked){
 	p.disabled=false;
 }else{
 	p.disabled=true;
 }
}

function activateEdit(){
		l= document.getElementById('cLabel');
		c=document.getElementById('cCat');
		d=document.getElementById('activatePeriod4');
		h=document.getElementById('hSaveButton');
		e=document.getElementById('period4');
		i=document.getElementById('cInput');
		x=document.getElementById('hIgnoreButton');
		m=document.getElementById('mSelect');
		
			m.disabled=true;
			c.disabled=false;
			d.disabled=false;
			l.disabled=false;
			e.disabled=false;
			i.disabled=false;
			
			
		x.style.visibility="visible";
		h.style.visibility="visible";
		

	
}

function deactiveEdit(){


		l= document.getElementById('cLabel');
		c=document.getElementById('cCat');
		d=document.getElementById('activatePeriod4');
		h=document.getElementById('hSaveButton');
		e=document.getElementById('period4');
		i=document.getElementById('cInput');
		x=document.getElementById('hIgnoreButton');
		m=document.getElementById('mSelect');
		
			c.disabled=true;
			d.disabled=true;
			l.disabled=true;
			i.disabled=true;

			e.disabled=true;
			m.disabled=false;
		
		
			
		
		h.style.visibility="hidden";
		x.style.visibility="hidden";

}



$(".restoreStandard").click(function(e) {
 bootbox.confirm("Wollen Sie wirklich die Standardeinstellungen wiederherstellen?", "Nein", "Ja", function() {
  console.log("Standard restored");
 });
});

$(".saveSetting").click(function(e) {
 bootbox.confirm("Wollen Sie wirklich die neuen Einstellungen speichern?", "Nein", "Ja", function() {
  console.log("Standard restored");
 });
});
	
	
	function test(){

		altert("juhu");
	}


	
	
		